#define _CRT_SECURE_NO_WARNINGS	

typedef struct word
{
    char* p;
    int len;
}word;

const int MAX = 10;

char* sortSentence(char* s)
{
    word arr[MAX];
    int len = strlen(s);
    int i, j, start, max;
    i = j = start = max = 0;
    for (i = 0; i < len; i++)
    {
        int num = s[i] - '0';
        if (num >= 1 && num <= 9)
        {
            arr[num].len = i - start + 1;
            arr[num].p = (char*)malloc(arr[num].len);
            for (j = 0; start < i; j++)
            {
                arr[num].p[j] = s[start++];
            }
            arr[num].p[j] = ' ';
            start = i + 2;
            max = (max > num) ? max : num;
        }
    }
    for (i = 0, j = 1; j <= max; j++)
    {
        for (int k = 0; k < arr[j].len; k++)
        {
            s[i++] = arr[j].p[k];
        }
        free(arr[j].p);
        arr[j].p = NULL;
    }
    s[i - 1] = '\0';
    return s;
}